package utils.easyui.domain;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * EasyUI tree模型
 * attributes=map ,attributes.put("isLeaf",false);
 * 
 * @author 孙宇
 * 
 */
public class EzTree implements java.io.Serializable {

	private String id;
	private String text;
	private String state="closed";// open,closed
	private boolean checked = false;
	private Map<String,Object> attributes=new HashMap<String, Object>();;
	private List<EzTree> children=new ArrayList<EzTree>();
	private String iconCls;
	private String pid;
	private boolean leaf=false;
	
	public EzTree(){
		attributes.put("isLeaf",false);
	}
	
	public EzTree(String id,String text){
		this();
		this.id=id;
		this.text=text;
	}
	
	public EzTree(String id,String text,String pid){
		this(id, text);
		this.pid=pid;
	}
	
	
	public EzTree(String id,String text,boolean isLeaf){
		this(id, text);
		leaf=isLeaf;
		attributes.put("isLeaf",isLeaf);
	}
	
	public EzTree(String id,String text,String pid,boolean isLeaf){
		this(id, text,isLeaf);
		this.pid=pid;
	}

	public boolean isLeaf() {
		return leaf;
	}

	public void setLeaf(boolean leaf) {
		attributes.put("isLeaf", leaf);
		this.leaf = leaf;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public boolean isChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}


	public List<EzTree> getChildren() {
		return children;
	}

	public void setChildren(List<EzTree> children) {
		this.children = children;
	}

	public String getIconCls() {
		return iconCls;
	}

	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}

	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}
	

	public Map<String, Object> getAttributes() {
		return attributes;
	}

	public void setAttributes(Map<String, Object> attributes) {
		this.attributes = attributes;
	}

	@Override
	public String toString() {
		return "Tree [id=" + id + ", text=" + text + ", state=" + state
				+ ", checked=" + checked + ", attributes=" + attributes
				+ ", children=" + children + ", iconCls=" + iconCls + ", pid="
				+ pid + "]";
	}

	
}
